package edu.biwu.cookie01;/**
 * @author 王俊彪
 * @version 1.0
 */

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.net.URLEncoder;

@WebServlet("/cookie/send")
public class SendCookie extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Cookie cookie = new Cookie("id", "123");
        response.addCookie(cookie);
//        response.addCookie(new Cookie("name","zhangsan"));
        response.addCookie(new Cookie("id","456"));
        String lisi = URLEncoder.encode("李四", "utf-8");
        response.addCookie(new Cookie("name",lisi));
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}
